1 From c59783780c8ad66f6076a9a7c74df3e006e29519 Mon Sep 17 00:00:00 2001
2 From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
3 Date: Sat, 24 May 2025 09:29:11 +0200
4 Subject: [PATCH] net: airoha: Fix an error handling path in
5 airoha_alloc_gdm_port()
7 If register_netdev() fails, the error handling path of the probe will not
8 free the memory allocated by the previous airoha_metadata_dst_alloc() call
9 because port->dev->reg_state will not be NETREG_REGISTERED.
11 So, an explicit airoha_metadata_dst_free() call is needed in this case to
14 Fixes: af3cf757d5c9 ("net: airoha: Move DSA tag in DMA descriptor")
15 Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
16 Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>
17 Reviewed-by: Simon Horman <horms@kernel.org>
18 Link: https://patch.msgid.link/1b94b91345017429ed653e2f05d25620dc2823f9.1746715755.git.christophe.jaillet@wanadoo.fr
19 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
21 drivers/net/ethernet/airoha/airoha_eth.c | 10 +++++++++-
22 1 file changed, 9 insertions(+), 1 deletion(-)
24 --- a/drivers/net/ethernet/airoha/airoha_eth.c
25 +++ b/drivers/net/ethernet/airoha/airoha_eth.c
26 @@ -2881,7 +2881,15 @@ static int airoha_alloc_gdm_port(struct
30 - return register_netdev(dev);
31 + err = register_netdev(dev);
33 + goto free_metadata_dst;
38 + airoha_metadata_dst_free(port);
42 static int airoha_probe(struct platform_device *pdev)